﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LHJ.Common.Extend
{
    public static class StringExtend
    {
        /// <summary>
        /// str转换base64 str
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string ToBase64Str(this string str)
        {
            byte[] b = Encoding.UTF8.GetBytes(str);
            return Convert.ToBase64String(b);
        }

        /// <summary>
        /// base64 str转str
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string FromBase64Str(this string str)
        {
            byte[] b = Convert.FromBase64String(str);
            return Encoding.UTF8.GetString(b);
        }
    }
}
